<?php
namespace Phone\Controller;
use Think\Controller;
use Org\wxsdk\jssdk;
/**
* 
*/
class FormController extends CommonController{
	//查询快递
	public function index(){
		//微信扫一扫
		$jssdk = new JSSDK();
		$this->assign("signPackage",$jssdk->getSignPackage());
		//货柜号
		$this->assign("container",$container = M('Container')
            ->where(array(
            	'user_id'=>session('id'),
            	'status'=>2
            	))->where("capacity-used>0")
            ->select());
		$this->display();
	}
	public function save(){
		$data=I("post.");
		$has = M('Take')->where(array('no'=>$data['no'],'user_id'=>session('id')))->find();
        $has && $this->error('快递号重复');
		!is_numeric($data['container_id']) && $this->error("请选择货柜号");
		$data['user_id']=session("id");
		!D("Take")->create($data) && $this->error(D("Take")->getError());
		session('container_id',$data['container_id']);
		M("Container")->where(array('id'=>$data['container_id']))->setInc('used');
		D("Take")->add($data)?$this->success("录入成功"):$this->error("保存失败,请重新登录");
	}
	
}